<?php

namespace App\Models\System;


use App\Models\BaseModel;

/**
 * 系统用户
 * Class SystemUser
 *
 * @package App
 */
class User extends BaseModel
{
    const STATUS_KEY = 'system_user_status';
    protected $table = 'system__users';
    /**
     * 字段
     * @var array
     */
    protected $fillable = [
        'id',
        'role_id',
        'group_code',
        'username',
        'status',
        'name',
        'email',
        'mobile',
        'password',
        'status',
        'salt',
        'avatar_id',
        'hospital_ids',
        'department_id',
        'deleted_at',
        'updated_at',
        'created_at'
    ];

    /**
     * 状态文本
     * @param $value
     * @return mixed
     */
    public function getStatusTextAttribute($value)
    {
        return $this->getCode(self::STATUS_KEY, $value);
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function role()
    {
        return $this->belongsTo(Role::class, 'role_id');
    }
}
